import requests

url = "http://www.baidu.com"
response = requests.get(url=url)

# 一个类型和六个属性
# Response类型
print(type(response)) # <class 'requests.models.Response'>
# 设置响应的编码格式
response.encoding = 'utf-8'
# 以字符串的形式来返回了网页的源码
print(response.text)
# 返回了一个url地址
print(response.url) # http://www.baidu.com/
# 返回的是二进制数据
print(response.content)
# 返回响应的状态码
print(response.status_code) # 200
# 返回的是响应头
print(response.headers) # {'Cache-Control': 'private, no-cache, no-store, proxy-revalidate, no-transform', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Content-Type': 'text/html', 'Date': 'Mon, 20 Sep 2021 07:14:55 GMT', 'Last-Modified': 'Mon, 23 Jan 2017 13:27:29 GMT', 'Pragma': 'no-cache', 'Server': 'bfe/1.0.8.18', 'Set-Cookie': 'BDORZ=27315; max-age=86400; domain=.baidu.com; path=/', 'Transfer-Encoding': 'chunked'}
